const path = require('path');
const fs = require('fs');
const Promise = require('./promise');
let p = new Promise((resolve,reject)=>{ // ← Promise的executor 是立即执行的,如果内部出错了 就会变成失败态 TODO notice1
    fs.readFile(path.resolve(__dirname,'./name.txt'), 'utf8', (err, data) => {
        if(err){
            return reject(err); // TODO notice 2.2 发布
        }
        resolve(data); // TODO notice 2.2 发布
    });
});
p.then((data)=>{ // TODO notice 2.1 订阅
    console.log('成功',data)
},(reason)=>{ // TODO notice 2.1 订阅
    console.log('失败',reason)
});

